using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Collections;
using System.Reflection;
using System.Linq;
using UMC.Wiki.Entities;
using UMC.Web;

namespace UMC.Wiki.Activities
{
    class SubjectNavsActivity : WebActivity
    {
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {

            var user = this.Context.Token.Identity();


            var code = this.AsyncDialog("code", g =>
            {
                return this.DialogValue("none");
            });



            var team = DataFactory.Instance().Project(code.ToLower());

            var projects = DataFactory.Instance().ProjectItem(new Project { Id = team.Id });
 
            var status = -1;
            var member = DataFactory.Instance().ProjectMember(team.Id.Value, user.Id.Value);


            var data = new List<WebMeta>(); 
            foreach (var p in projects)
            {
                var meta = new WebMeta();
                meta.Put("id", p.Id).Put("text", p.Caption).Put("path", String.Format("{0}/{1}", team.Code, p.Code));


                if (p.Hide == true)
                {
                   
                    meta.Put("hide", true);
                }

                meta.Put("subs", SubjectPortfolioSubActivity.Portfolio(team, p, status));



                data.Add(meta);
            }

            response.Redirect(data);


        }

    }
}